package com.neuedu.corejava.ch10.homework;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import com.neuedu.corejava.ch10.Computer;

//使用Set集合，存放学生对象
public class Test1 {

	public static void main(String[] args) {
		Student student1=new Student("AA",160,20);
		Student student2=new Student("BB",160,21);
		Student student3=new Student("CC",160,22);
		
		Set studentSet=new HashSet();
		studentSet.add(student1);
		studentSet.add(student2);
		studentSet.add(student3);
		
		System.out.println(studentSet.size());
		
		Iterator iterator =studentSet.iterator();
		while(iterator.hasNext()) {//hasNext判断集合中是否有下一条数据
			Object object=iterator.next();//取出条数据，并把指针下移
		    Student  stu=(Student)object;
		    System.out.println(stu);
		}

	}

}
